﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 专业违章性质管理
/// </summary>
[Route("QHSEDangerClause/[action]")]
[ApiController]
public class QHSEDangerClauseController : ControllerBase
{
    private readonly QHSEDangerClauseService _specialtyDangerService;

    public QHSEDangerClauseController(QHSEDangerClauseService specialtyDangerService)
    {
        _specialtyDangerService = specialtyDangerService;
    }

    /// <summary>
    /// 隐患条款列表
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEDangerClauseModel> data = await _specialtyDangerService.GetAsync();
        return AppResult.Status200OK(data: data);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> List1()
    {
        List<QHSEDangerClauseModel> data = await _specialtyDangerService.GetAsync();
        return AppResult.Status200OK(data: data);
    }

    /// <summary>
    /// 专业隐患条款查询
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> ClausePage([FromBody] IdInputModel input)
    {
        var data = await _specialtyDangerService.GetByNameAsync(input);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 专业隐患条款查询
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    //[CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> GetClause([FromBody] IdInputModel input)
    {
        var data = await _specialtyDangerService.GetByIdAsync(input);
        return AppResult.Status200OK(data: data);
    }

}

